import 'package:flutter/material.dart';
import 'package:qimeng/colorall.dart';

class setting extends StatefulWidget {
  const setting({super.key});

  @override
  State<setting> createState() => _settingState();
}

class _settingState extends State<setting> {
  bool select = false;
  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: Kbgcolor,
      appBar: AppBar(
        elevation: 0,
        scrolledUnderElevation: 0,
        backgroundColor: Kappbarcolor,
        leading: InkWell(
          onTap: () {
            Navigator.pop(context);
          },
          child: Image.asset('assets/切图/组 16.png'),
        ),
        title: Text(
          '设置',
          style: TextStyle(
              fontSize: 36, color: Ktitlecolor, fontWeight: FontWeight.w900),
        ),
      ),
      body: Padding(
        padding: EdgeInsets.all(size.width * 0.07),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            settingitem(
              size: size,
              action: RotatedBox(
                quarterTurns: 2,
                child: Switch(
                    activeColor: Color(0xffFD7968),
                    value: select,
                    onChanged: (value) {
                      setState(() {
                        select = !select;
                      });
                    }),
              ),
              icon: 'assets/切图/组 69.png',
              title: '随机模式',
            ),
            settingitem(
              size: size,
              icon: 'assets/切图/组 70.png',
              title: '分享给好友',
            ),
            settingitem(
              size: size,
              icon: 'assets/切图/组 71.png',
              title: '检查新版本',
              action: Text(
                '1.0.0',
                style: TextStyle(
                    fontSize: 36,
                    color: Color(0xffA2A2A2),
                    fontWeight: FontWeight.w500),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class settingitem extends StatelessWidget {
  final String icon;
  final String title;
  final Widget? action;
  const settingitem({
    super.key,
    required this.size,
    required this.icon,
    required this.title,
    this.action = null,
  });

  final Size size;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: size.height * 0.05),
      width: size.width,
      height: size.height * 0.08,
      decoration: BoxDecoration(
        border: Border(bottom: BorderSide(color: Color(0xffFD7968))),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Image.asset(
            icon,
            scale: 2,
          ),
          SizedBox(
            width: 10,
          ),
          Expanded(
            child: Text(
              title,
              style: TextStyle(
                  fontSize: 36, color: Ktextcolor, fontWeight: FontWeight.w900),
            ),
          ),
          if (action != null) action! else Text(''),
        ],
      ),
    );
  }
}
